-
Notifications
You must be signed in to change notification settings - Fork 24
Prevent doom loop on broken RPC frames #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Validate every inbound message is valid single-value RLP before processing; if framing is broken, log and close the connection since recovery is impossible. Add regression tests covering invalid RLP closure and the customer-reported broken frame, while ensuring valid-but-unsupported requests don’t close the client.
Summary of ChangesHello @tuhalf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical stability issue where malformed RPC frames could lead to client 'doom loops.' It introduces robust RLP validation for all incoming messages. If an inbound message exhibits unrecoverable broken RLP framing, the connection is now gracefully closed to prevent continuous processing of invalid data. Crucially, this change ensures that valid RPC requests, even if unsupported by the client, do not trigger connection closures, maintaining client resilience. Comprehensive test cases have been added to validate these new behaviors. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a robust mechanism to handle broken RPC frames by validating inbound RLP messages. If a message is not a valid, single-value RLP, the connection is now correctly closed to prevent processing loops. This is a critical fix for connection stability. The change is well-supported by a new suite of regression tests that cover invalid RLP, valid but unsupported requests, and the specific broken frame that triggered the original issue. My review includes a couple of suggestions to improve the new test code for better maintainability and robustness.
| cfg := testConfig() | ||
| config.AppConfig = cfg | ||
| pool := NewPool() | ||
| client := NewClient("localhost:0", nil, cfg, pool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This client setup logic is repeated across TestHandleInboundMessage_ClosesOnInvalidRLP, TestHandleInboundMessage_DoesNotCloseOnValidUnsupportedRequest, and TestHandleInboundMessage_ClosesOnBrokenFrameFromLog. To improve maintainability and reduce code duplication, consider extracting this into a test helper function.
For example:
func newTestClient(t *testing.T) *Client {
t.Helper()
cfg := testConfig()
config.AppConfig = cfg
pool := NewPool()
return NewClient("localhost:0", nil, cfg, pool)
}Each test could then be simplified to start with client := newTestClient(t).
| t.Fatalf("expected invalid RLP for reported frame") | ||
| } | ||
|
|
||
| msg := edge.Message{Len: 398, Buffer: buf} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message length is hardcoded as 398. It's more robust to use len(buf) to dynamically set the length. This ensures the test remains correct even if the test data in buf is modified in the future.
| msg := edge.Message{Len: 398, Buffer: buf} | |
| msg := edge.Message{Len: len(buf), Buffer: buf} |
|
We have no validation yet that this is solving the issue in the field, but the artificial unit tests show that at least the RLP test works. |
Fixes issue: #197
Validate every inbound message is valid single-value RLP before processing; if framing is broken, log and close the connection since recovery is impossible. Add regression tests covering invalid RLP closure and the customer-reported broken frame, while ensuring valid-but-unsupported requests don’t close the client.